Getting a config file for a country
In TPN every config file you request has 2 attributes:
- The country you want to connect to
- The lease time of the config file
You may opt to connect to a specific country, or to specify "any" as the country, which will connect you to a random country.
The lease time is the duration of the config file. After this time, the config file will stop working. Lease time is defined in minutes.
The format of API calls is as follows:
# [GET] http://$VALIDATOR_IP:3000/api/config/new?format={json,text}&geo={COUNTRY_CODE}&lease_minutes={LEASE_MINUTES}
curl http://$VALIDATOR_IP:3000/api/config/new?format=json&geo=any&lease_minutes=.5
# Response format for format=json
{
peer_config: String, # Usage-ready wireguard config
expires_at: Number # Javascript timestamp (Unix, milliseconds)
}
This is an example call in JSON format, meaning the response will be a JSON object:
# Example call (json)
curl http://185.189.44.166:3000/api/config/new?geo=any&lease_minutes=.5
# Example response
{
peer_config: '
[Interface]
ListenPort = 51820
PrivateKey = 6M5yn+TkOMv4CeFONLkz6aJ4QcZUzo+hOeacJQvHHHM=
[Peer]
PublicKey = dU9hNqdcPbLe9GXSZYHq7DE/AlgZI7o8bX0/4S9fGn4=
PresharedKey = tcFzfBM0LJ3f17eWGR66tT6H9MEvy4W5RtmfN9h385o=
AllowedIPs = 0.0.0.0/0, ::/0
Endpoint = 176.9.26.135:51820
',
expires_at: 1744834696579
}
This is an example call in text format, meaning the response will be a plain text string:
# Example call (text)
curl http://185.189.44.166:3000/api/config/new?format=text&geo=any&lease_minutes=.5
# Example response
[Interface]
ListenPort = 51820
PrivateKey = 6M5yn+TkOMv4CeFONLkz6aJ4QcZUzo+hOeacJQvHHHM=
[Peer]
PublicKey = dU9hNqdcPbLe9GXSZYHq7DE/AlgZI7o8bX0/4S9fGn4=
PresharedKey = tcFzfBM0LJ3f17eWGR66tT6H9MEvy4W5RtmfN9h385o=
AllowedIPs = 0.0.0.0/0, ::/0
Endpoint = 176.9.26.135:51820